classic_battlefield_moddingfandomcom-20200214-history
Understanding Navmesh Materials
Understanding Navmesh Materials The materials.mtl file defines the "materials" that represent something for a navmesh. The possible materials are "ground", "ladder', "water", and "deepwater". The different materials are shown as different colours: Green for ground, Yellow for water, Blue for deepwater and Red for Ladder material. (Above is a example navmesh showing ground and water) A navmesh created by BF2Editor will never have any faces under the "ladder" material. DICE tried to get the bots to use ladders but ran into problems. Since the ladder material already existed in BF2Editor, the Material Group for ladder (g ladder) and the "use material" entries for ladder (usemtl ladder) will always be created. To keep the bots from getting "stuck" DICE changed BF2Editor so that it would never create any faces with ladder material when it made a navmesh. Also, the bot AI code was changed so that if a bot touched a "ladder" it would "jump off" and go somewhere else. Therefore the only usable materials for a Navmesh are "ground", "water", and "deepwater". How Materials are defined in the Navmesh The Infantry.obj or Vehicle.obj navmesh files use a materials.mtl files in the same folder. The materials.mtl file defines the "materials" used by the navmesh. The obj format can be read by any text editor such as Notepad. In the obj format, the materials are defined as follows: - All of the Material Groups g ground g ladder g water g deepwater - All of the materials Used to make a "Face" usemtl ground usemtl ladder usemtl water usemtl deepwater An .obj file from BF2Editor will have each Material Group with the material directly below it because BF2Editor "gathers" all the entries of the same material together. i.e. g ground usemtl ground Every Face entry under a "usemtl" line all use the material at the top of the list. i.e. g ground usemtl ground Setting Materials in 3dsmax For minor edits to a Navmesh, the materials will normally not need to be edited. But, for major editing, it is easier to import a navmesh with the needed materials, then use the 'get material' eyedropper on it. set the colors as shown to make it easier to understand which material is which. A setting of 50% transparency is useful so that overlaps etc. are easier to spot. (The image above shows the material editor in 3ds Max v 7) A useful tip for major editing in 3dsMax, is to add two special materials to your max materials library, called Default and Default2, The Default2 material is identical except for the colour-shift; to use for preopt and manifold objects, in order to have these and the navmesh both visible at the same time and still tell which object is which. Every time you import a new navmesh, get these materials from the library and apply Default to both the Infantry/Vehicle meshes and go on from there. To set this in 3ds Max, Open the Material Editor, and select any empty material slot. Name this material 'Default' Change its type to Multi/Sub-Object. Change 'Set Number' to 3. You should now see the three sub-materials we will use; one for each material type that navmeshes use - ground, water, and deep water. Name these materials in that order so that their material IDs match the names: 1 is 'ground' - give this material a green colour.** 2 is 'water' - make this material yellow. 3 is 'deepwater' - make this one blue. One thing i find helpful is to make each of these materials 50% transparent - it has no effect whatsoever on the mesh itself, but makes it easier to make out when one piece of mesh is above another, like you may find with bridges, multi-storey buildings etc. Now clone the entire 'Default' material you just made, and call it 'Default2' Make the colour of ID1 'ground' magenta.** Make the colour of ID2 'water' purple. Make the colour of ID3 'deep water' cyan. This second material is for applying to the preopt object if you need to import it, or for adding to a cloned piece of navmesh where it is important to tell the clone from the original on-screen. The colours for Default2 were chosen because they sit well with the colours in the Default material - sometimes they will each be on overlapping objects, and you will want to be able to discern which object has which material. Now add both Default and Default2 to your Max material library. **You can use any colours you like, but to avoid confusion in this tutorial it would be better to use those colours suggested.